package com.lxf.clouduser.mapper;

import com.lxf.clouduser.bean.UserBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 罗兴发
 * @data 2025/6/23 11:54
 * @description：es持久层
 */
@Component
public interface UserItemRepository extends ElasticsearchRepository<UserBean, String> {

    /**
     * 根据用户名分页模糊查询
     * @param userName 用户名
     * @return 返回关键字高亮的结果集
     */
    @Highlight(
            fields = {@HighlightField(name = "userName")},
            parameters = @HighlightParameters(preTags = {"<span style='color:red'>"}, postTags = {"</span>"}, numberOfFragments = 0)
    )
    Page<SearchHit<UserBean>> findUserBeanByUserName(String userName,Pageable pageable);

    /**
     * 根据是否是客服查询
     * @param isKf 是否客服
     * @return 返回关键字高亮的结果集
     */
    List<UserBean> findUserBeanByIsKf(Integer isKf);
}